<!doctype html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
</head>
<body>
	<!--header start -->
	{include file="header"}
	<!--header end-->


    <table class="weui-table weui-border-tb" id="cusTable">
		<thead>
			<tr>
				<th  data-field="username" style="border-left:2px solid #fff">姓名</th>
				<th>昵称</th>
				<th>头像</th>
				<th>公司</th>
				<th>职位</th>
				<th>邮箱</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
				{volist name="data" id="vo"}
					<tr>
						<td data-field="" id="sub" style="border-left:2px solid #fff">{$vo.username}</td>
						<td>{:base64_decode($vo.nickname)}</td>
						<td><img src="{$vo.headimage}" style="width: 50px"></td>
						<td>{$vo.company}</td>
						<th>{$vo.position}</th>
						<td>{$vo.email}</td>
						<th><a href="###" onclick="change(this)" statusid="{$vo.audit}" data_id="{$vo.id}"><span >{$vo.audit == 1?'正常':'失效'}</span></a></th>
						<th>
							<a href="{:url('edit',array('id'=>$vo.id))}" id="edit" data-id="{$vo.id}"><span class="icon icon-115" title="编辑">编辑</span></a>
							<a href="###" id="delete" data-id="{$vo.id}" onclick="del(this)"><span class="icon icon-23"  title="删除">删除</span></a>
						</th>
					</tr>
				{/volist}

		</tbody>
	</table>

	<div class="pages">{$page}</div>
	<!--footer start -->
	{include file="footer"}
	<!--footer end-->
	<script src="__STATIC__/js/common/jquery.js"></script>
	<script src="__STATIC__/js/parsley.js"></script>
	<script src="__STATIC__/js/zh_cn.js"></script>
	<script>
//		删除
		function del(_this){
		    var uid = $(_this).attr('data-id');
		    $.ajax({
				type:'post',
				url:"{:url('User/delete')}",
				data:{'uid':uid},
				success:function(data){

                    switch(data){
						case 1:
						    $(_this).parent().parent().remove();
						    break;
                        case 2:
                            alert('删除失败');
                            break;
                        case 3:
                            alert('用户不存在');
                            break;
                        case 4:
                            alert('请求格式不对');
                            break;
					}
				}
			})
		}


		//修改状态
		function change(_this){
		    var statusid = $(_this).attr('statusid');
		    var uid = $(_this).attr('data_id');

		    $.ajax({
				type:'post',
				url:"{:url('User/changestatus')}",
				data:{'statuid':statusid,'id':uid},
				success:function(data){
				    if(data.msg == '修改成功'){
//				        console.log(data.statuid);
				        if(data.statuid == 1){
                              var test = $(_this).find('span');
                              var test1 = $(_this).attr('statusid',1);
                              test.text('正常');
						}else{
                            var test = $(_this).find('span');
                            var test1 = $(_this).attr('statusid',0);
                            test.text('失效');
						}

					}
				}
			})
		}
	</script>
</body>
</html>